<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>

<script type="text/javascript">

// name space for this page
var p01_cworder_add = {
	mid: "${menuId}",
	focusId: "p01_cworder_member_id"
};


// fill cust info by member ID
p01_cworder_add.fillCustInfoByMemberId = function() {
	var memberId = Ext.String.trim(Ext.getCmp("p01_cworder_member_id").getValue());
	if (crm.utils.isEmpty(memberId)) {
		return;
	}

	Ext.Ajax.request({
		url: "cworder/check_memberinfo.shtm",
		params: {
			member_id : memberId
		},
		success: function(resp, opts) {
			var json = Ext.JSON.decode(resp.responseText);
		    			
		}
	});
};

// add panel
p01_cworder_add.addPanel = Ext.create("Ext.form.Panel", {
	region: "center",
    frame: true,
    bodyPadding: 5,
    defaults: {
        xtype: "fieldset",
        layout: "anchor",
        defaults: {
            xtype: "container",
            anchor: "100%",
            layout: "hbox",
            defaultType: "textfield",
            padding: "2 0",
            defaults: {
                labelAlign: "left",
                labelWidth: 120,
                width: 280,
                labelStyle: "padding-left: 15px"
            }
        }
    },
    items: [{
        title: "联系人信息",
        items: [ {
        	items: [{
        		id: "p01_cworder_member_id",
                fieldLabel: "会员卡号",
                name: "member_id",
                enableKeyEvents: true,
                listeners: {
                    keyup: {
                        fn: function(text, evt, opts) {
                            if (evt.getKey() == Ext.EventObject.ENTER) {
                            	p01_cworder_add.fillCustInfoByMemberId();
                            }
                        }
                    }
                }
        	}, {
        		xtype: "button",
        		text : "查询",
        		width : 50,
        		handler : function() {
        			p01_cworder_add.fillCustInfoByMemberId();
        		}
        	}]
        }, {
            items: [{
                id: "p01_cworder_add_mobile",
                fieldLabel: "手机号码",
                name: "mobile",
                allowBlank: false
            }]
        }, {
            items: [{
                fieldLabel: "姓名",
                name: "name",
                allowBlank: false
            }]
        }, {
        	items: [{
                xtype: "fieldcontainer",
                fieldLabel: "性别",
                defaultType: "radiofield",
                defaults: {
                    flex: 1
                },
                layout: "hbox",
                items: [{
                    boxLabel: "男",
                    name: "gender",
                    checked: true,
                    inputValue: "1"
                }, {
                    boxLabel: "女",
                    name: "gender",
                    inputValue: "2"
                }]
            }]
        }, {
            items: [{
                fieldLabel: "联系电话一",
                name: "phone1"
            }/*, {
                fieldLabel: "联系电话二",
                name: "phone2"
            }*/]
        }]
    }, {
        title: "预约信息",
        items: [ {
        	items : [ {
                fieldLabel: "车牌号码",
                name: "car_id",
                allowBlank: false
            }, {
                xtype : "uXcombo",
                name : "car_size_type",
                comboOpts : {
                    comboId : crm.consts.CDD_CD0002
                },
                fieldLabel : "车体类型",
                labelWidth : 120,
                width : 280,
                allowBlank: false
            }]
        }, {
            items: [{
                xtype: "datefield",
                format: "Y-m-d",
                fieldLabel: "日期",
                name: "order_date",
                emptyText: "服务日期",
                editable: false,
                allowBlank: false
            }]
        }, {
        	items: [ {
                xtype: "timefield",
                name: "time_st",
                minValue: "8:30",
                maxValue: "17:00",
                format: "G:i",
                fieldLabel: "时间从",
                emptyText: "最早",
                editable: false,
                allowBlank: false
            }, {
                xtype: "timefield",
                name: "time_end",
                fieldLabel: "到",
                emptyText: "最晚",
                minValue: "9:00",
                maxValue: "17:30",
                format: "G:i",
                editable: false,
                allowBlank: false
            }]
        }, {
            items: [{
                fieldLabel: "地址",
                name: "addr",
                width: 560
            }]
        }]
    }, {
        title: "套餐及费用",
        items: [{
            items: [{
                fieldLabel: "套餐",
                name: "svc_package"
            }, {
                fieldLabel: "费用",
                name: "total_fee"
            }]
        }]
    }, {
    	xtype: "container",
        frame: true,
        layout: "anchor",
        margin: "10 0",
        items: [{
        	xtype: "container",
            defaults: {
                xtype: "button",
                style: "margin-right: 5px; padding: 2px 20px"
            },
            items: [{
                text: "重置",
                handler: function() {
                    this.up("form").getForm().reset();
                    Ext.getCmp(p01_cworder_add.foucsId).focus();
                }
            }, {
                text: "保存",
                handler: function() {
                    this.up("form").getForm().submit({
                        url: "cworder/add.shtm",
                        success: function(form, action) {
                            if (action.result.success == "true") {
                                Ext.Msg.alert("信息提示", "保存成功");
                            }
                        },
                        faliure: function(form, action) {
                            Ext.Msg.alert("提示信息", action.result.errorMsgs);
                        }
                    });
                }
            }]
        }]
    }]
});

//show tab content
p01_cworder_add.items = [p01_cworder_add.addPanel];
crm.utils.showTabContent(p01_cworder_add);

</script>

